
// hello world
console.log('hello world')
console.log("hello world")

// 基础语法

// 基础类型 int , string, double ,float, boolean

var a = 1;	// int
var b = 1;	// int
var c = 'hello world';	// string
var d = 1.0;
var e = true;

console.log('a=' + a)
// console.log('a=', a)
console.log('b=' + a)


// 比较运算符
var aa = 1;
var bb = 2;
if (aa > bb) {
	console.log('aa > bb')
} else {
	console.log('bb > aa')
}

// 数组
console.log('===========数组============')
var list = [];	// 更通用
var list2 = [1, 2, 3]; // ['a', 'b']
var list3 = new Array();

list.push(1)
list.push(3)
list.push(2)
console.log(list);

list.sort();
console.log(list);

console.log(list[1]);

list.reverse();
console.log(list);



// 对象
console.log('===========对象============')

var obj2 = {k1 : 'v1', k2 : 'v2'}

console.log(obj2)

var obj = {}
obj.k1 = 'v1'
obj.k2 = 'v2'
console.log(obj)

var obj = {}
obj['k1'] = 'v1'
obj['k2'] = 'v2'
console.log(obj)


// 字符串操作todo


// 循环
console.log('===========循环============')
for (var i = 1; i <= 5; i++) {
    console.log('i=' + i)
}

var obj3 = {k1 : 'v1', k2 : 'v2'}
for (var key in obj3) {
    console.log(key + "=" + obj3[key]); // 不能用obj3.key
}


// 函数
console.log('===========函数============')

function sayHi() {
	console.log('say hi')
}

sayHi();


function sayHi2(name, age) {
	console.log('say hi name=' + name + ', age=' + age)
}
sayHi2('Tom', 21)




